home *** CD-ROM | disk | FTP | other *** search
- /*
- * std.h
- * An ANSI'ish prototype decl. file for the MINIX C library
- * Only decls that do not need additional struct defs are in this
- * file. The protos for decls that need some struct definitions
- * are in the respective <*.h> files. This was done to avoid
- * #includ'ing the world here.
- * Note: this file by no means fully conforms to the Ansi C docs
- * in terms of types of args and returned values. I tried to come close
- * without breaking/re-writing the minix (i have the ST version only)
- * lib src. Any updates/fixes/suggestions are most welcome.
- *
- * ++jrb bammi@dsrgsun.ces.cwru.edu or {decvax,sun}!cwjcc!dsrgsun!bammi
- *
- * Random Notes:
- * - A lot of the prototypes like malloc, read,write,fread,bcopy, mem etc
- * should really be specified as taking the type size_t for their
- * count arguement. This was not done as it would require quite a
- * bit of change to the library source and some of the system calls.
- *
- * - When using Gnu CC -mshort (ie. 16 bit integers) one should be
- * aware that the `sizeof' operator yields a long and *not* an int.
- * What this means is calling malloc(sizeof(X)) is incorrect, and
- * will NOT do the right thing. Now if you have the prototype
- * `void *malloc(unsigned);' the compiler will coerce the
- * arguement in a `malloc(sizeof(X))' call correctly to an unsigined
- * int and the call will do the right thing. But if you declare
- * malloc as `extern void *malloc()' or `extern char *malloc()'
- * the call `malloc(sizeof(X))' will not do the right thing. The
- * same arguement applies to other calls too, where you are
- * passing sizeof(X) as a parameter to a routine that expects an int
- * arguement. Please be aware of this when writing/porting code. Of
- * course when the -mshort flag is not used (32 bit ints) there is
- * no problem.
- * - The above behaviour is totally consistent with the Ansi Draft
- * standard and K&R second edition.
- *
- * - I am against changing size_t to unsigned int, beacuse that
- * would imply that no structure can be bigger than 64K
- * (in the -mshort case when ints are 16 bits) since
- * you could not take its sizeof(X). That would really cripple
- * the compiler in my opinion.
- *
- * - whenver you use mgcc -short now, you have to careful
- * about using sizeof. If you have
- * void *malloc(unsigned);
- * malloc(sizeof(X));
- * there is no problem, as the compiler will see the prototype
- * and will cast the second statement to `malloc((unsiged)sizeof(X))'
- * BUT is you have
- * extern void *malloc() or extern char *malloc();
- * malloc(sizeof(X));
- * then there is a problem beacuse the compiler will push a long
- * and malloc will see garbage.
- *
- * - Your comments are of course always welcome.
- *
- */
-
- #ifndef _STD_H
- #define _STD_H 1
-
- #ifdef NO_POOLE_FS
- # ifdef WANT_POOLE_FS
- # undef WANT_POOLE_FS
- # endif
- #else
- # ifndef WANT_POOLE_FS
- # define WANT_POOLE_FS
- # endif
- #endif
-
- #ifdef __STDC__
- #ifndef __NO_PROTO__
- #ifdef __NO_CONST__
-
- #define _CONST /* */
- #else
- #define _CONST const
- #endif
-
- void _cleanup(void);
-
- void abort(void);
- int abs(int);
- int access(_CONST char *, int);
- unsigned alarm(unsigned);
- void * alloca(unsigned long);
- int atexit(void (*)(void));
- double atof(_CONST char *);
- int atoi(_CONST char *);
- long atol(_CONST char *);
-
- int bcmp(_CONST void *, _CONST void *, long);
- void bcopy(_CONST void *, void *, long);
- void * brk(void *);
- void brk2(void);
- void bzero(void *, long);
- char * bsearch(char *, char *, unsigned int, unsigned int,
- int(*)(char *, char *));
-
- int callm1(int, int, int, int, int, _CONST void *,
- _CONST void *, _CONST void *);
- int callm3(int, int, int, _CONST char *);
- void * calloc(unsigned, unsigned);
- int callx(int, int);
- void cfree(void *, unsigned, unsigned);
- int chdir(_CONST char *);
- int chmod(_CONST char *, int);
- int chown(_CONST char *, int, int);
- int chroot(_CONST char *);
- int close(int);
- int creat(_CONST char *, int);
- char * crypt(char *, _CONST char *);
- char * ctime(_CONST long *);
- char * ctermid(char *);
- char * cuserid(char * );
-
- int dup(int);
- int dup2(int, int);
-
- void encrypt(char *, int);
- void endgrent(void);
- void endpwent(void);
- int execl(_CONST char *, _CONST char *, ...);
- int execle(_CONST char *, _CONST char *, ...);
- int execlp(_CONST char *, _CONST char *, ...);
- int execn(_CONST char *);
- int execv(_CONST char *, _CONST char **);
- int execve(_CONST char *, _CONST char **, char **);
- int execvp(_CONST char *, _CONST char **);
- void exit(int);
- int _exit(int);
-
- int ffs(int);
- int fork(void);
- void free(void *);
- #if (defined(__MSHORT__) || defined(SHORTLIB))
- double frexp(double, short *);
- #else
- double frexp(double, int *);
- #endif
-
- char * getcwd( char *, int);
- char getegid(void);
- char * getenv(_CONST char *);
- short geteuid(void);
- char getgid(void);
- int gethostname( char *, int);
- char * getlogin(void);
- int getopt(int, char **, char *);
- char * getpass(_CONST char *);
- int getpid(void);
- int getpgrp(void);
- int getppid(void);
- char * gets(char *);
- short getuid(void);
- char * getwd(char *);
-
- char * index(_CONST char *, int);
- int isatty(int);
- char * itoa(int);
-
- int kill(int, int);
-
- double ldexp(double, int);
- #ifdef SHORTLIB
- double __ldexp(double, long);
- #endif
-
- int len(_CONST char *);
- int link(_CONST char *, _CONST char *);
- int lock(_CONST char *);
- long lrand(void);
- long seed(long);
- char * lsearch( char *, char *, unsigned *, unsigned,
- int(*)(char *, char *));
- char * lfind( char *, char *, unsigned *, unsigned,
- int(*)(char *, char *));
- long lseek(int, long, int);
-
- void * malloc(unsigned);
- void * memccpy(void *, _CONST void *, int, int);
- void * memchr(_CONST void *, int, int);
- int memcmp(_CONST void *, _CONST void *, int);
- void * memset(void *, int, int);
- #ifdef WANT_POOLE_FS
- int mkfifo(_CONST char *name, int);
- #endif /* WANT_POOLE_FS */
- int mknod(_CONST char *, int, int);
- char * mktemp(char *);
- double modf(double, double *);
- int mount(_CONST char *, _CONST char *, int);
-
- int nice(int);
-
- #ifndef WANT_POOLE_FS
-
- #ifdef EMUL_OPEN3
- #ifdef __SRC__
- extern int open();
- #else
- int open(_CONST char *, int, int);
- #endif /* __SRC__ */
- #else
- #ifdef OPEN3
- /* this is just to fool the prototyping */
- int open(_CONST char *, int, int);
- #else
- int open(_CONST char *, int);
- #endif /* OPEN3 */
- #endif /* EMUL_OPEN3 */
-
- #else /* WANT_POOLE_FS */
-
- #ifdef __SRC__
- int open(_CONST char *, int, int);
- #else
- int open(_CONST char *, int, ...);
- #endif /* __SRC__ */
- #endif /* WANT_POOLE_FS */
-
- int pause(void);
- void perror(_CONST char *);
- int pipe(int *);
- #ifdef __SRC__
- int printf(_CONST char *, int);
- #else
- int printf(_CONST char *, ...);
- #endif
- #ifndef printk
- #ifdef __SRC__
- void printk(_CONST char *, int);
- #else
- void printk(_CONST char *, ...);
- #endif
- #endif /* printk */
- #ifdef __SRC__
- void prints(_CONST char *, char *);
- #else
- void prints(_CONST char *, ...);
- #endif
- long ptrace(int, int, long, long);
- int puts(_CONST char *);
- int putenv(char *);
-
- void qsort(void *, unsigned long, unsigned long,
- int(*)(_CONST void *, _CONST void *));
-
- int rand(void);
- int read(int, void *, int);
- void * realloc(void *, unsigned);
- int rename(_CONST char *, _CONST char *);
- char * rindex(_CONST char *, int);
-
- void * sbrk(int);
- #ifdef __SRC__
- int scanf(_CONST char *, int);
- #else
- int scanf(_CONST char *, ...);
- #endif
- int setgid(int);
- int setgrent(void);
- int sethostname( char *, int );
- void setkey(_CONST char *);
- int setpgrp(void);
- int setpwent(void);
- int setuid(int);
- unsigned sleep(unsigned);
- #ifdef __SRC__
- char * sprintf(char *, _CONST char *, int);
- #else
- char * sprintf(char *, _CONST char *, ...);
- #endif
- void srand(long);
- #ifdef __SRC__
- int sscanf(_CONST char *, _CONST char *, int);
- #else
- int sscanf(_CONST char *, _CONST char *, ...);
- #endif
- void std_err(_CONST char *);
- int stime(long *);
- char * strcat(char *, _CONST char *);
- int strcmp(_CONST char *, _CONST char *);
- char * strcpy(char *, _CONST char *);
- int strcspn(_CONST char *, _CONST char *);
- char * strerror(int);
- int strlen(_CONST char *);
- char * strncat(char *, _CONST char *, int);
- int strncmp(_CONST char *, _CONST char *, int);
- char * strncpy(char *, _CONST char *, int);
- char * strpbrk(_CONST char *, _CONST char *);
- int strspn(_CONST char *, _CONST char *);
- char * strstr(_CONST char *, _CONST char *);
- char * strtok(char *, _CONST char *);
- void swab(void *, void *, int);
- int sync(void);
- void sys_abort(void);
- void sys_exec(int, void *, int);
- void sys_fork(int, int, int, unsigned short);
- void sys_fresh(int, void *, unsigned short, unsigned short *,
- unsigned short *);
- void sys_getsp(int, long *);
- void sys_kill(int, int);
- void sys_newmap(int, void *);
- void sys_nice(int, int);
- void sys_sig(int, int, int(*)());
- void sys_times(int, long *);
- int sys_trace(int, int, long, long *);
- void sys_xit(int, int, unsigned short *, unsigned short *);
- int system(_CONST char *);
-
- void tell_fs(int, int, int, int);
- int tgetent(char *, _CONST char *);
- int tgetflag(_CONST char *);
- int tgetnum(_CONST char *);
- char * tgetstr(_CONST char *, char **);
- char * tgoto(_CONST char *, int, int);
- long time(long *);
- char * tmpname(char *);
- char * tempnam(char *, char *);
- int tolower(int);
- int toupper(int);
- int tputs(_CONST char *, int, int(*)());
- char * ttyname(int);
-
- int umask(int);
- int umount(_CONST char *);
- int unlink(_CONST char *);
- void unlock(_CONST char *);
- int utime(_CONST char *, long *);
-
- int wait(int *);
- /* SHOULD it BE ?? int write(int, void *, unsigned); */
- int write(int, _CONST void *, int);
-
- #ifdef __MSHORT__
- void * lmemset(void *, int, long);
- int lmemcmp(_CONST void *, _CONST void *, long);
- void * lmemchr(_CONST void *, int, long);
- void * lmemccpy(void *, _CONST void *, int, long);
- void * lmalloc(unsigned long);
- void * lrealloc(void *, unsigned long);
- void * lcalloc(unsigned long, unsigned long);
-
- #endif /* __MSHORT__ */
-
- #endif /* __NO_PROTO__ */
-
- #ifndef _CONST
- #define _CONST const
- #endif
-
- #define VOIDSTAR void *
-
- #else
-
- #define _CONST /* get yourself a modern C compiler! */
- #define VOIDSTAR char *
-
- #endif /* __STDC__ */
-
- #define SIZET int
- #define memcpy(dst, src, size) bcopy(src, dst, (long)size)
- #define strchr index
- #define strrchr rindex
-
- #ifndef __MSHORT__
- #define lmemset memset
- #define lmemcmp memcmp
- #define lmemchr memchr
- #define lmemccpy memccpy
- #define lmalloc malloc
- #define lrealloc realloc
- #define lcalloc calloc
- #endif
-
- #define lbzero bzero
- #define lbcopy bcopy
- #define lbcmp bcmp
-
- #endif /* _STD_H */
-